package day7.zhujie;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class CalcTest {
    public static void main(String[] args) throws Exception {
        Calc c1=new Calc();
        c1.brand="卡西欧";
        Calc c2=new Calc();
        c2.brand="卡西欧";
        List<Calc> list=new ArrayList<>();
        list.add(c1);
        list.add(c2);
        Calc c3=new Calc();
        c3.brand="卡西欧";
        System.out.println(list.contains(c3)+"? true");
        System.out.println(">>>>>>>>>>");
        Calc c=new Calc();
        String methodName="div";
        Method m = c.getClass().getDeclaredMethod(methodName, int.class, int.class);
        if (m.isAnnotationPresent(MyTest.class)) {//加了注解
            MyTest mt=m.getAnnotation(MyTest.class);
            System.out.println(mt.before());
            Object invoke = m.invoke(c, 10, 20);
            System.out.println(invoke);
            System.out.println(mt.after());
        }else{
            Object invoke = m.invoke(c, 10, 20);
            System.out.println(invoke);
        }

//        int h = c.add(10, 20);
//        System.out.println(h);
    }
}
